package com.itheima.blog.admin.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.blog.admin.dto.OperationLogDto;
import com.itheima.blog.admin.entity.OperationLogTable;
import com.itheima.blog.admin.service.IOperationLogTableService;
import com.itheima.common.domain.PageReqDto;
import com.itheima.common.domain.PageResDto;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zwp
 * @since 2023-07-11
 */
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class OperationLogTableController {
    private final IOperationLogTableService operationLogTableService;
    @ApiOperation("操作日志接口")
    @GetMapping("/system/operate/log")
    public PageResDto<OperationLogTable> getOpertion(Integer size , Integer page ,@RequestBody(required = false) OperationLogDto operationLogDto){
        PageReqDto pageReqDto = new PageReqDto();
        pageReqDto.setPage(page);
        pageReqDto.setSize(size);
        IPage<OperationLogTable> opertion = operationLogTableService.getOpertion(pageReqDto, operationLogDto);
        PageResDto pageResDto = new PageResDto<>(pageReqDto,opertion.getTotal(),opertion.getRecords());
        pageResDto.setCode(200);
        return pageResDto;
    }
}
